home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1995 #5 & #6 / Amiga Plus CD - 1995 - No. 5 and 6.iso / pd / netz / term / extras / source / gtlayout-source.lha / LTP_DrawGroup.c < prev    next >
C/C++ Source or Header  |  1995-04-23  |  10KB  |  299 lines

  1. /*  GadTools layout toolkit
  2. **
  3. **  Copyright © 1993-1995 by Olaf `Olsen' Barthel
  4. **  Freely distributable.
  5. */
  6.  
  7. #include "gtlayout_global.h"
  8.  
  9. VOID __regargs
  10. LTP_DrawObjectLabel(LayoutHandle *Handle,ObjectNode *Node)
  11. {
  12.     LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  13.  
  14.     switch(Node -> LabelPlace)
  15.     {
  16.         case PLACE_LEFT:
  17.  
  18.             LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2);
  19.             break;
  20.  
  21.         case PLACE_RIGHT:
  22.  
  23.             LTP_PrintLabel(Handle,Node,Node -> Left + Node -> Width + INTERWIDTH + INTERWIDTH + Node -> LabelWidth,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2);
  24.             break;
  25.  
  26.         case PLACE_ABOVE:
  27.  
  28.             LTP_PrintLabel(Handle,Node,Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT));
  29.             break;
  30.  
  31.         case PLACE_BELOW:
  32.  
  33.             LTP_PrintLabel(Handle,Node,Node -> Left + (Node -> Width - Node -> LabelWidth) / 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top + Node -> Height + INTERHEIGHT);
  34.             break;
  35.     }
  36. }
  37.  
  38. VOID __regargs
  39. LTP_DrawGroup(LayoutHandle *Handle,ObjectNode *Group)
  40. {
  41.     ObjectNode    *Node;
  42.     LONG         i;
  43.     ULONG         page;
  44.  
  45.     if(Group -> Label || Group -> Special . Group . Frame)
  46.         LTP_DrawLabel(Handle,Group);
  47.  
  48.     SCANPAGE(Group,Node,page)
  49.     {
  50.         switch(Node -> Type)
  51.         {
  52.             case BUTTON_KIND:
  53.  
  54.                 if(Handle -> ReturnKey == Node)
  55.                     LTP_DrawBevelBox(Handle,Node);
  56.  
  57.                 break;
  58. #ifdef DO_GAUGE_KIND
  59.             case GAUGE_KIND:
  60.             {
  61.                 LONG Percent = Node -> Current;
  62.  
  63.                 Node -> Current = 0;
  64.  
  65.                 LTP_DrawGauge(Handle,Node,Percent,TRUE);
  66.  
  67.                 break;
  68.             }
  69. #endif
  70.             case PALETTE_KIND:
  71.  
  72.                 if(Node -> Special . Palette . UsePicker)
  73.                     LTP_DrawPalette(Handle,Node);
  74.  
  75.                 break;
  76.  
  77.             case GROUP_KIND:
  78.  
  79.                 if(Node -> Label)
  80.                     LTP_DrawLabel(Handle,Node);
  81.  
  82.                 LTP_DrawGroup(Handle,Node);
  83.  
  84.                 break;
  85.  
  86.             case XBAR_KIND:
  87.             {
  88.                 WORD Top = Node -> Top + ((Node -> Height + 1) / 2) - 1;
  89.  
  90.                 LockLayerRom(Handle -> RPort . Layer);
  91.  
  92.                 if(Node -> Special . Bar . FullSize)
  93.                 {
  94.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  95.                     Move(&Handle -> RPort,Handle -> Window -> BorderLeft,Top);
  96.                     Draw(&Handle -> RPort,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top);
  97.  
  98.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  99.                     Move(&Handle -> RPort,Handle -> Window -> BorderLeft,Top + 1);
  100.                     Draw(&Handle -> RPort,Handle -> Window -> Width - (Handle -> Window -> BorderRight + 1),Top + 1);
  101.                 }
  102.                 else
  103.                 {
  104.                     if(Node -> Special . Bar . Parent -> Label)
  105.                     {
  106.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  107.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth,Top + 1);
  108.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth,Top);
  109.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1) - 1,Top);
  110.  
  111.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  112.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 2 * Handle -> GlyphWidth + 1,Top + 1);
  113.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1),Top + 1);
  114.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - (2 * Handle -> GlyphWidth + 1),Top);
  115.                     }
  116.                     else
  117.                     {
  118.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  119.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left,Top + 1);
  120.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left,Top);
  121.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top);
  122.  
  123.                         LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  124.                         Move(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + 1,Top + 1);
  125.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top + 1);
  126.                         Draw(&Handle -> RPort,Node -> Special . Bar . Parent -> Left + Node -> Special . Bar . Parent -> Width - 1,Top);
  127.                     }
  128.                 }
  129.  
  130.                 UnlockLayerRom(Handle -> RPort . Layer);
  131.  
  132.                 break;
  133.             }
  134.  
  135.             case YBAR_KIND:
  136.             {
  137.                 WORD Left = Node -> Left + ((Node -> Width + 1) / 2) - 1;
  138.  
  139.                 LockLayerRom(Handle -> RPort . Layer);
  140.  
  141.                 if(Node -> Special . Bar . Parent -> Label)
  142.                 {
  143.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  144.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight);
  145.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight);
  146.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1) - 1);
  147.  
  148.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  149.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Handle -> RPort . TxHeight + Handle -> InterHeight + 1);
  150.                     Draw(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1));
  151.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - (Handle -> RPort . TxHeight + Handle -> InterHeight + 1));
  152.                 }
  153.                 else
  154.                 {
  155.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShadowPen);
  156.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top);
  157.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top);
  158.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1 - 1);
  159.  
  160.                     LTP_SetAPen(&Handle -> RPort,Handle -> ShinePen);
  161.                     Move(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + 1);
  162.                     Draw(&Handle -> RPort,Left + 1,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1);
  163.                     Draw(&Handle -> RPort,Left,Node -> Special . Bar . Parent -> Top + Node -> Special . Bar . Parent -> Height - 1);
  164.                 }
  165.  
  166.                 UnlockLayerRom(Handle -> RPort . Layer);
  167.  
  168.                 break;
  169.             }
  170.  
  171.             case FRAME_KIND:
  172.  
  173.                 if(Node -> Special . Frame . DrawBox)
  174.                     LTP_DrawBevelBox(Handle,Node);
  175.  
  176.                 if(Node -> Special . Frame . RefreshHook)
  177.                 {
  178.                     RefreshMsg Message;
  179.  
  180.                     Message . ID        = Node -> ID;
  181.                     Message . Left        = Node -> Left;
  182.                     Message . Top        = Node -> Top;
  183.                     Message . Width        = Node -> Width;
  184.                     Message . Height    = Node -> Height;
  185.  
  186.                     if(Node -> Special . Frame . DrawBox)
  187.                     {
  188.                         Message . Left        += 4;
  189.                         Message . Top        += 2;
  190.                         Message . Width        -= 8;
  191.                         Message . Height    -= 4;
  192.                     }
  193.  
  194.                     CallHookPkt(Node -> Special . Frame . RefreshHook,Handle,&Message);
  195.                 }
  196.  
  197.                 // FALL THROUGH TO...
  198.  
  199.             case BOOPSI_KIND:
  200.  
  201.                 // FALL THROUGH TO...
  202.  
  203.             case TAPEDECK_KIND:
  204.  
  205.                 if(Node -> Label)
  206.                     LTP_DrawObjectLabel(Handle,Node);
  207.  
  208.                 break;
  209.  
  210.             case MX_KIND:
  211.  
  212.                 if(Node -> Label && !V39)
  213.                     LTP_PrintLabel(Handle,Node,Node -> Left,Node -> Top + (Node -> Height - Handle -> RPort . TxHeight) / 2 + 1);
  214.  
  215.                 break;
  216.  
  217.             case LISTVIEW_KIND:
  218.  
  219.                 if(Node -> Special . List . ExtraLabels)
  220.                 {
  221.                     LockLayerRom(Handle -> RPort . Layer);
  222.  
  223.                     LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  224.  
  225.                     for(i = 0 ; Node -> Special . List . ExtraLabels[i] ; i++)
  226.                     {
  227.                         LONG Len = strlen(Node -> Special . List . ExtraLabels[i]);
  228.  
  229.                         LTP_PlaceText(Handle,Node -> Special . List . ExtraLabels[i],Len,Node -> Left - (TextLength(&Handle -> RPort,Node -> Special . List . ExtraLabels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle -> RPort . TxHeight + Handle -> RPort . TxBaseline);
  230.                     }
  231.  
  232.                     UnlockLayerRom(Handle -> RPort . Layer);
  233.                 }
  234.  
  235.                 if(Node -> Label)
  236.                 {
  237.                     if(Node -> LabelPlace == PLACE_ABOVE && Node -> Special . List . FlushLabelLeft)
  238.                     {
  239.                         struct TextFont *Font = NULL,*OldFont;
  240.  
  241.                         if(Node -> Special . List . TextAttr)
  242.                         {
  243.                             if(Font = LTP_OpenFont(Node -> Special . List . TextAttr))
  244.                             {
  245.                                 OldFont = Handle -> RPort . Font;
  246.  
  247.                                 SetFont(&Handle -> RPort,Font);
  248.                             }
  249.                             else
  250.                                 break;
  251.                         }
  252.  
  253.                         LTP_PrintLabel(Handle,Node,Node -> Left + 2 + INTERWIDTH + Node -> LabelWidth,Node -> Top - (Handle -> RPort . TxHeight + INTERHEIGHT));
  254.  
  255.                         if(Font)
  256.                         {
  257.                             SetFont(&Handle -> RPort,OldFont);
  258.  
  259.                             CloseFont(Font);
  260.                         }
  261.                     }
  262.                     else
  263.                     {
  264.                         if(Node -> Special . List . TextAttr && Node -> Label)
  265.                             LTP_DrawObjectLabel(Handle,Node);
  266.                     }
  267.                 }
  268.  
  269.                 break;
  270.  
  271.             case BOX_KIND:
  272.  
  273.                 Node -> Special . Box . Parent = Group;
  274.  
  275.                 if(Node -> Special . Box . DrawBox)
  276.                     LTP_DrawBevelBox(Handle,Node);
  277.  
  278.                 LockLayerRom(Handle -> RPort . Layer);
  279.  
  280.                 for(i = 0 ; i < Node -> Lines ; i++)
  281.                 {
  282.                     if(Node -> Special . Box . Labels && Node -> Special . Box . Labels[i])
  283.                     {
  284.                         LONG Len = strlen(Node -> Special . Box . Labels[i]);
  285.  
  286.                         LTP_SetPens(&Handle -> RPort,Handle -> TextPen,Handle -> BackgroundPen,JAM2);
  287.                         LTP_PlaceText(Handle,Node -> Special . Box . Labels[i],Len,Node -> Left - (TextLength(&Handle -> RPort,Node -> Special . Box . Labels[i],Len) + INTERWIDTH),Node -> Top + 2 + i * Handle -> RPort . TxHeight + Handle -> RPort . TxBaseline);
  288.                     }
  289.  
  290.                     LTP_PrintBoxLine(Handle,Node,i);
  291.                 }
  292.  
  293.                 UnlockLayerRom(Handle -> RPort . Layer);
  294.  
  295.                 break;
  296.         }
  297.     }
  298. }
  299.